package redis

import (
	"encoding/json"
	"fmt"
	"time"
	"yuekaoHouse/house_srv/house"
)

// 优化缓存房源列表
func RedisHouseList(title string, sel []*house.Houses) string {
	key := "HouseList:" + title
	se := RedisDB.Get(key).Val()

	if se == "" {
		marshal, err := json.Marshal(sel)
		if err != nil {
			fmt.Println("转json失败")
			return ""
		}
		RedisDB.Set(key, marshal, time.Hour*10) //有效期10小时
	}
	return RedisDB.Get(key).Val()

}
